#ifndef BITMAP_H_INCLUDED
#define BITMAP_H_INCLUDED

#include "texture.h"

namespace sheeplib {

	namespace texture {

		typedef unsigned char 	byte;
		typedef unsigned short 	word;
		typedef unsigned long dword;

#ifdef _MSC_VER
#	pragma pack( push, packing )
#	pragma pack( 1 )
#	define PACK_STRUCT
#elif defined( __GNUC__ )
#	define PACK_STRUCT	__attribute__((packed))
#else
#	error you must byte-align these structures with the appropriate compiler directives
#endif

		struct BITMAPFILEHEADER {
		  word    bfType;
		  dword   bfSize;
		  word    bfReserved1;
		  word    bfReserved2;
		  dword   bfOffBits;
		}PACK_STRUCT;

		//Bitmap information header
		//provides information specific to the image data
		struct BITMAPINFOHEADER {
		  dword  biSize;
		  long   biWidth;
		  long   biHeight;
		  word   biPlanes;
		  word   biBitCount;
		  dword  biCompression;
		  dword  biSizeImage;
		  long   biXPelsPerMeter;
		  long   biYPelsPerMeter;
		  dword  biClrUsed;
		  dword  biClrImportant;
		} PACK_STRUCT;

		//Colour palette
		struct RGBQUAD {
		  byte    rgbBlue;
		  byte    rgbGreen;
		  byte    rgbRed;
		  byte    rgbReserved;
		} PACK_STRUCT;

// Default alignment
#ifdef _MSC_VER
#	pragma pack( pop, packing )
#endif

#undef PACK_STRUCT

		class Bitmap : public Texture {
			private:
				bool Convert24(vector<byte>& tempData, long padWidth, long byteWidth, dword dataSize);
				bool Convert8(vector<byte>& tempData, vector<RGBQUAD>& colourTable, long padWidth, long byteWidth, dword dataSize);
			public:
				Bitmap();
				~Bitmap();

				bool LoadTextureFile(const string& filename);
		};
	}
}

#endif // BITMAP_H_INCLUDED
